<%--
  Created by IntelliJ IDEA.
  User: 风间琉璃
  Date: 2021/4/29
  Time: 14:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>流水</title>
</head>
<body>
    <form action="BooksServlet" method="post">
        <table>
            <tr>
                <td>
                    时间：<input type="text" name="time"/>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="submit" value="提交">
                </td>
            </tr>
        </table>
    </form>
    <table border="1">
        <tr>
            <th>
                bid
            </th>
            <th>
                uid
            </th>
            <th>
                sid
            </th>
            <th>
                aid
            </th>
            <th>
                wid
            </th>
            <th>
                amount
            </th>
            <th>
                remark
            </th>
            <th>
                time
            </th>
        </tr>
        <c:forEach items="${booksList}" var="books" varStatus="status">
            <tr <c:if test="${status.index % 2 == 0}">style="background-color: #123456"</c:if>>

                <td>
                        ${books.bid}
                </td>
                <td>
                        ${books.uid}
                </td>
                <td>
                        ${books.sid}
                </td>
                <td>
                        ${books.aid}
                </td>
                <td>
                        ${books.wid}
                </td>
                <td>
                        ${books.amount}
                </td>
                <td>
                        ${books.remark}
                </td>
                <td>
                        ${books.time}
                </td>
            </tr>
        </c:forEach>
    </table>
    <div class="bigContainer">
        <div>
            <form id="user_form" action="javascript:void(0)" method="post" enctype="multipart/form-data">
                头像：<input type="file" name="photo">
                <button type="submit">OK</button>
            </form>
        </div>
    </div>
    <script src="js/jquery-1.8.3.js"></script>
    <script>
        $("#user_form").submit(function () {
            var form = document.getElementById("user_form");//获取表单的数据
            var formdata = new FormData(form);//格式化表单数据
            console.log(formdata);
            $.ajax({
                url:"ServletUpload",
                data:formdata,
                processData: false,
                contentType : false,
                dataType:"json",
                type:"post",
                success:function (data){
                    alert(data);
                }
            })
        })
    </script>
</body>
</html>
